﻿<%@ Page Title="" Language="C#" MasterPageFile="~/template_faa/master/faa_main.Master" AutoEventWireup="true" %>

<asp:Content ID="Content4" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" type="text/css" href="../ascx/easyui/demo/demo.css"/>
    <link rel="stylesheet" type="text/css" href="../css/left_nav.css"/>
    <script type="text/javascript" src="../scripts/datagrid-detailview.js"></script>
    <script type="text/javascript" src="../scripts/left_nav.js"></script>
    
    <!--表单提交处理-->
    <%
        
        if (Request["cmd"] =="post" )
        {
            string sql = "insert into [zhiFaDW] (zfdwName, zfdwAbbr, zfdwAddr, zfdwLinkman, zfdwTel) values(@zfdwName, @zfdwAbbr, @zfdwAddr, @zfdwLinkman, @zfdwTel)";
            System.Data.SqlClient.SqlParameter paraName = jsm.SqlHelper.SqlServerHelper.CreateInputParameter("@zfdwName", System.Data.SqlDbType.NVarChar, 100, Request["name"]);
            System.Data.SqlClient.SqlParameter paraAbbr = jsm.SqlHelper.SqlServerHelper.CreateInputParameter("@zfdwAbbr", System.Data.SqlDbType.NVarChar, 100, Request["simple_name"]);
            System.Data.SqlClient.SqlParameter paraAddr = jsm.SqlHelper.SqlServerHelper.CreateInputParameter("@zfdwAddr", System.Data.SqlDbType.NVarChar, 100, Request["address"]);
            System.Data.SqlClient.SqlParameter paraLinkman = jsm.SqlHelper.SqlServerHelper.CreateInputParameter("@zfdwLinkman", System.Data.SqlDbType.NVarChar, 100, Request["linkman"]);
            System.Data.SqlClient.SqlParameter paraTel = jsm.SqlHelper.SqlServerHelper.CreateInputParameter("@zfdwTel", System.Data.SqlDbType.NVarChar, 100, Request["telephone"]);
            int rc = jsm.SqlHelper.SqlServerHelper.ExecuteNonQuery(sql, paraName, paraAbbr, paraAddr, paraLinkman, paraTel);
            if (rc == 1)
            {
                Response.Write("<script language=javascript>alert('保存成功')</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('保存失败')</script>");
            }
        }
    %>
    
    <script type="text/javascript" id="for datagrid">
        $(document).ready(
            function() {
                loadGrid();
            }
        );

        function loadGrid() {
            $('#dg').datagrid({
                width: 'auto',
                height: 365,
                idField: 'jlbh',                        //表明该列是一个唯一列    
                striped: true,                          //设置为true将交替显示行背景
                singleSelect: true,                     //设置为true将只允许选择一行
                url: 'getDanWeiList.ashx',               //用以从远程站点请求数据的超链接地址
                loadMsg: '数据加载中请稍后……',         //当从远程站点载入数据时，显示的一条快捷信息
                pagination: true,                       //设置true将在数据表格底部显示分页工具栏
                rownumbers: true,                       //设置为true将显示行数
                toolbar: '#datagrid_tb',                //工具栏
                columns: [[                              //数据表格列配置对象
                    {field: 'zfdwId', title: '编号', align: 'center', width: 80 },
                    { field: 'zfdwName', title: '名称', align: 'center', width: 80 },
                    { field: 'zfdwAbbr', title: '简称', align: 'center', width: 80 },
                    { field: 'zfdwAddr', title: '地址', align: 'center', width: 200 },
                    { field: 'zfdwLinkman', title: '联系人', align: 'center', width: 80 },
                    { field: 'zfdwTel', title: '电话', align: 'center', width: 80 },
                    { field: 'admin', title: '操作', align: 'center', width: 100,
                        formatter: function(value, rec, index) {
                            var s = '<a href="#" onclick="alert(' + index + ')">查看</a> ';
                            var e = '<a href="#" onclick="modifyItem(' + index + ')">编辑</a> ';
                            var d = '<a href="#">删除</a> ';
                            return s + " | " + e + " | " + d;
                        }
                    }
                ]],

                // 添加记录详细信息展示
                view: detailview,
                detailFormatter: function(index, row) {
                    return '<div id="ddv-' + index + '" style="padding:5px 0"></div>';
                },
                onExpandRow: function(index, row) {
                    $('#ddv-' + index).panel({
                        height: 80,
                        border: false,
                        cache: false,
                        href: 'admin_DanWei_getdetail.aspx?itemid=' + index,
                        onLoad: function() {
                            $('#dg').datagrid('fixDetailRowHeight', index);
                        }
                    });
                    $('#dg').datagrid('fixDetailRowHeight', index);
                }


            });
        }
    </script>

    <script language="javascript" type="text/javascript" id="for dialog">
        function submitForm() {
            $('#dlg').dialog('close');
            $('#ff').form('submit');
        }
        function clearForm() {
            $('#ff').form('clear');
        }

        function addItem() {
            $('#dlg').dialog({
                title: '新建执法单位',
            });
            $('#dlg').dialog('open').dialog('setTitle', '新建执法单位');
        }

        function modifyItem(index) {
            // 设置对话框显示
            $('#dlg').dialog({
                title: '修改执法单位',
                width: 400,  
                height: 200,  
                closed: false,  
                cache: false,  
                //href: 'get_content.php',  
                modal: true  
            });  
            
            // 加载对话框编辑内容
            $('#ff').form('load', 'getDanWeiItemByIndex.ashx?itemId='+index);	
            
            // 显示对话框
            $('#dlg').dialog.open();
        }

    </script>
    
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="body_left" runat="server">
    <div id="navigator">
        <ul id="listUL">
            <li><a href="#">Home</a></li>
            <li><a href="#">News</a>
                <ul class="myHide">
                    <li><a href="#">Latest News</a></li>
                    <li><a href="#">All News</a></li>
                </ul>
            </li>
            <li><a href="#">Sports</a>
                <ul class="myHide">
                    <li><a href="#">Basketball</a></li>
                    <li><a href="#">Football</a></li>
                    <li><a href="#">Volleyball</a></li>
                </ul>
            </li>
            <li><a href="#">Weather</a>
                <ul class="myHide">
                    <li><a href="#">Today's weather</a></li>
                    <li><a href="#">Forecast</a></li>
                </ul>
            </li>
            <li><a href="#">Contact me</a></li>
        </ul>
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body_right_top" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="body_right_bottom" runat="server">
    <!--list data grid--->
    <table id="dg" title="行政执法单位管理"></table>         
    
    <!--datagrid toolbar-->
    <div id="datagrid_tb" style="width:100%">
        <table cellpadding="0" cellspacing="0" style="width:100%">  
            <tr>  
                <td style="width:60px">  
                    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="javascript:addItem()">新增</a>  
                </td>  
                 <td style="width:60px">  
                    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="javascript:alert('导入')">导入</a>  
                </td> 
                <td style="text-align:right">  
                    <input/> 
                    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:$('#dd').dialog('search')"></a>  
                </td>  
            </tr>  
        </table>
    </div>
    
    <!--dialog for add-->
    <div id="dlg" class="easyui-dialog" title="" style="width:400px;height:200px;padding:10px"  
            data-options="buttons: '#dlg-buttons', closed: true">
        <form id="ff" method="post">
            <table>
                <tr>
                    <td>
                        单位名称：
                    </td>
                    <td>
                        <input class="easyui-validatebox" type="text" name="name" data-options="required:true"></input>
                    </td>
                </tr>
                <tr>
                    <td>
                        单位简称：
                    </td>
                    <td>
                        <input class="easyui-validatebox" type="text" name="simple_name" data-options="required:true"></input>
                    </td>
                </tr>
                <tr>
                    <td>
                        单位地址：
                    </td>
                    <td>
                        <input class="easyui-validatebox" type="text" name="address" data-options="required:true"></input>
                    </td>
                </tr>
                <tr>
                    <td>
                        联系人：
                    </td>
                    <td>
                        <input class="easyui-validatebox" type="text" name="linkman" data-options="required:true"></input>
                    </td>
                </tr>
                <tr>
                    <td>
                        联系电话：
                    </td>
                    <td>
                        <input class="easyui-validatebox" type="text" name="telephone" data-options="required:true"></input>
                    </td>
                </tr>
            </table>
            <input type="hidden" name="cmd" value="post" />
        </form>
        
    </div>  
        
    <!--dialog buttons for add-->
    <div id="dlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:submitForm()">保存</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:clearForm()">重置</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#dlg').dialog('close')">关闭</a>  
    </div>
    


</asp:Content>
